home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 60914 / 60914.xpi / chrome / content / setdesktopbackgroundoverlay.js < prev    next >
Text File  |  2010-01-20  |  3KB  |  79 lines

  1. var setDesktopBackgroundOverlay={
  2.  
  3.     DOMContentLoaded:function(event){
  4.     
  5.         setDesktopBackgroundOverlay.STRINGS=document.getElementById("overlayBundle");
  6.     
  7.     },
  8.  
  9.     load:function(event){
  10.     
  11.         if(window.arguments[1]){
  12.         
  13.             var edit=window.arguments[1].edit;
  14.             var collection=window.arguments[1].collection;
  15.             
  16.             if(collection) document.getElementsByClassName("personasrotatorgroupbox")[0].removeAttribute("hidden");
  17.             
  18.             if(edit){
  19.             
  20.                 setTimeout(function(self) {
  21.                 
  22.                     var color = window.arguments[1].backgroundcolor;
  23.                     const rMask = 4294901760;
  24.                     const gMask = 65280;
  25.                     const bMask = 255;
  26.                     var r = (color & rMask) >> 16;
  27.                     var g = (color & gMask) >> 8;
  28.                     var b = (color & bMask);
  29.                     gSetBackground.updateColor(gSetBackground._rgbToHex(r, g, b));
  30.                     var colorpicker = document.getElementById("desktopColor");
  31.                     colorpicker.color = gSetBackground._backgroundColor;
  32.                     
  33.                     
  34.                     var position=window.arguments[1].position;
  35.                     if(position=="CENTER") document.getElementById("menuPosition").selectedIndex=0;
  36.                     else if(position=="TILE") document.getElementById("menuPosition").selectedIndex=1;
  37.                     else if(position=="STRETCH") document.getElementById("menuPosition").selectedIndex=2;
  38.                     gSetBackground._image = window.arguments[0];
  39.                     gSetBackground._canvas.width = gSetBackground._canvas.clientWidth;
  40.                     gSetBackground._canvas.height = gSetBackground._canvas.clientHeight;
  41.                     var ctx = gSetBackground._canvas.getContext("2d");
  42.                     ctx.scale(gSetBackground._canvas.clientWidth / gSetBackground._screenWidth, gSetBackground._canvas.clientHeight / gSetBackground._screenHeight);
  43.                     gSetBackground.updatePosition();
  44.              
  45.                 }, 0, this);
  46.  
  47.                 document.documentElement.getButton("accept").label=setDesktopBackgroundOverlay.STRINGS.getString("saveChanges");
  48.                 
  49.                 document.documentElement.setAttribute("ondialogaccept","setDesktopBackgroundOverlay.saveChanges(event);");
  50.                 
  51.                 document.documentElement.setAttribute("title",setDesktopBackgroundOverlay.STRINGS.getString("editPersona"));
  52.  
  53.                 //alert(document.getAnonymousNodes(document.documentElement)[1].childNodes.length)
  54.         
  55.             }
  56.         }
  57.     
  58.     },
  59.     
  60.     saveChanges:function(event){
  61.         
  62.         var backgroundColor=gSetBackground._hexStringToLong(gSetBackground._backgroundColor);
  63.         
  64.         var position=gSetBackground._position;
  65.         
  66.         var editchanges={position:position,backgroundcolor:backgroundColor}
  67.  
  68.         window.opener.PersonasWindow.saveEditPersonaChangesGlobally(window.arguments[1].filename,editchanges,null)
  69.  
  70.     },
  71.     
  72.     STRINGS:null,
  73.  
  74. }
  75.  
  76. window.addEventListener("DOMContentLoaded",setDesktopBackgroundOverlay.DOMContentLoaded,false);
  77. window.addEventListener("load",setDesktopBackgroundOverlay.load,false);
  78.  
  79.